﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using FlightClient.FlightService;

namespace FlightClient
{

    public partial class Form1 : Form
    {
        static FlightService.IFlightService flightServiceObj = new FlightService.FlightServiceClient();
        City from;
        City to;
        int noOfSeats;
        public Form1()
        {
           InitializeComponent();
           IList<City> cities = flightServiceObj.GetCityList();
           IList<City> theSecondList = flightServiceObj.GetCityList();

           cityFromChoice.DataSource = cities;
           cityFromChoice.DisplayMember = "Name";
           cityToChoice.DataSource = theSecondList;
           cityToChoice.DisplayMember = "Name";
           City from = null;
           City to = null;
           int noOfSeats = 0;
            
            //foreach(City c in cities)
            //{
              
            //    cityFromChoice.Items.Add(c);
                
            //}
        }
        public override string ToString()
        {
            return base.ToString();
        }
        
        private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
        {

        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void dateTimePicker2_ValueChanged(object sender, EventArgs e)
        {

        }

        private void timeLabel_Click(object sender, EventArgs e)
        {

        }

        private void cityFromLabel_Click(object sender, EventArgs e)
        {

        }

        private void userSettingsGroupBox_Enter(object sender, EventArgs e)
        {

        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void cityFromChoice_SelectedIndexChanged(object sender, EventArgs e)
        {
            
           ComboBox cmb = (ComboBox)sender;
            from = (City)cmb.SelectedItem;
            airportFromName.Text = from.Country; 
        }

        private void airportFromName_TextChanged(object sender, EventArgs e)
        {

        }
        
        private void cityToChoice_SelectedIndexChanged(object sender2, EventArgs e)
        {
            ComboBox cmb1 = (ComboBox)sender2;
            City to = (City)cmb1.SelectedItem;
            airportToName.Text = to.Country;
        }

        private void noOfSeatsBox_TextChanged(object sender, EventArgs e)
        {
            TextBox seatNoBox = (TextBox)sender;
             noOfSeats = int.Parse(seatNoBox.Text);
        }

        private void searchButton_Click(object sender, EventArgs e)
        {
            if(from != null && to != null && noOfSeats != 0 && from != to)
            {
            }
        }
    }
}
